<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <% String path = request.getContextPath();%>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>密保问题验证</title>
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" href="<%=path %>/assets/images/favicon-32x32.png">
    <!-- Base Styling  -->
    <link rel="stylesheet" href="<%=path %>/assets/main/css/fonts.css">
    <link rel="stylesheet" href="<%=path %>/assets/main/css/style.css">
</head>

<body>
    <div id="main-wrapper" class="show">

        <div class="login-tabib">
            <div>
                <div class="text-center">
                    <a class="logo" >
                        <img class="img-fluid" src="<%=path %>/assets/images/logo.png" alt="loogin page">
                    </a>
                </div>
                <div class="login-main">
                    <form class="theme-form">
                        <h4>请选择您的密保问题 </h4>
                        <div class="form-group">
                            <select class="form-control form-select" id="ques">
                            
                               <option>请选择您的密保问题</option>
                             	<c:forEach items="${requestScope.userQuestion }" var="userQuestion" varStatus="sta">
                             		<option value="${userQuestion.id }" >${userQuestion.question }</option>
                             	</c:forEach>
                            </select>
                        </div>
                        <div class="form-group m-b-10">  
                            <div class="form-input position-relative">
                                <input class="form-control" type="text" placeholder="输入您的答案" id="answer" name="answer">
                                <div class="show-hide"><span class="show"></span></div>
                            </div>
                        </div>
                        <div class="form-group mb-0">
                            <div class="mt-3">
<!--                               下一步就会显示要修改的密码界面-->
                                <button class="btn btn-primary w-100" id="next" type="button">下一步</button>
                            </div>
                        </div>
                        <p class="mt-4 mb-0">记起您的密码?<a class="ms-2 text-primary text-center" href="<%=path%>/web/userLogin.jsp">登录</a>
                        </p>
                    </form>
                </div>
            </div>
        </div>

    </div>

    <!-- JQuery v3.5.1 -->
   <%--  <script src="<%=path %>/js/jquery-3.6.0.min.js"></script>  --%>
 	
	<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.js"></script>
	
    <!-- popper js -->
    <script src="<%=path %>/assets/plugins/popper/popper.min.js"></script>

    <!-- Bootstrap -->
   <%--  <script src="<%=path %>/assets/plugins/bootstrap/js/bootstrap.js"></script> --%>

    <!-- Moment -->
    <script src="<%=path %>/assets/plugins/moment/moment.min.js"></script>

    <!-- Date Range Picker -->
    <script src="<%=path %>/assets/plugins/daterangepicker/daterangepicker.min.js"></script>

    <!-- Main Custom JQuery -->
    <script src="<%=path %>/assets/js/toggleFullScreen.js"></script>
    <script src="<%=path %>/assets/js/main.js"></script>

</body>

<script type="text/javascript">
var path = "${pageContext.request.contextPath}";


function verification(){
	var ques = $("#ques").val();
	var answer = $("#answer").val();
	
	$.ajax({
		url:path+"/ForgetController?action=isRight",
		type:"post",
		data:{quesID:ques,answer:answer},
		success:function(data){
			if(data=="have"){
				location.href=path+"/web/user/updateForgetPassword.jsp";
				
			}
			else{
				alert("答案输入错误，请再次解答");
			}
		}
	});
	
}
	
		
	$(function(){
		$("#next").on("click",verification);
	});
</script>
</html>